#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <chat.h>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    mySocket = new QTcpSocket;

}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_connectButton_clicked()
{
    QString ip = ui->ipLineEdit->text();
    QString port = ui->portLineEdit->text();
    mySocket->connectToHost(ip, port.toShort());

    connect(mySocket, &QTcpSocket::connected, [this]{
        qDebug()<< "connect";
    });
}

void MainWindow::on_sendButton_clicked()
{
    Chat *chat = new Chat(mySocket);
    this->hide();
    chat->show();
}
